package tyk.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/*
* 全局异常拦截器
* */
//@RestControllerAdvice
public class MyExceptionHandler {


    /*
    * 拦截自定义异常，并且响应给前端
    * */
    @ExceptionHandler(MyException.class)
    public Result<String> run(MyException e) {

        return Result.error(e.getMessage());
    }


    /*
     * 拦截非自定义异常，并且响应给前端
     * */
    @ExceptionHandler(Exception.class)
    public Result<String> run(Exception e) {

        return Result.error("服务器内部异常，非自定义异常");
    }
}
